package com.dtsheep.mybatis.enums;

/**
 * @Description GenderTypeEnum
 * @Author siyuan
 * @Date 2021/1/8 上午10:44
 */
public enum GenderTypeEnum {

    /**
     * 男
     */
    MAN(0, "男"),
    /**
     * 女
     */
    WOMAN(1, "女"),
    /**
     * 其他
     */

    OTHER(2,"其他"),
    BEPENGDING(3, "待定");

    private Integer type;
    private String desc;

    GenderTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static GenderTypeEnum getGenderByWechatSex(Integer sex) {
        if (sex == 1) {
            return MAN;
        } else if (sex == 2) {
            return WOMAN;
        }
        return OTHER;
    }

    public static GenderTypeEnum getGenderByDesc(String desc) {
        if (null == desc) return null;
        for (GenderTypeEnum type : GenderTypeEnum.values()) {
            if (type.getDesc().equals(desc)) {
                return type;
            }
        }
        return null;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
